#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i <= r; i++)
#define int long long
using namespace std;
const int MN = 1e5 + 5;
//Nijika The Rock!!!
//Theme Using(VSCode): Red.
//I am totally Insane. 
int Choke();
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while(T--) Choke();
    return 0;
}
vector<int> p;
int lb(int n, double q) {
        int l = 1, r = n;
        while(l < r) {
            int mid = l + r >> 1;
            if(p[mid] <= q) l = mid + 1;
            else r = mid;
        }
    return r;
}
int Choke() {
    //15:27
    int n, m;
    double L, V;
    cin >> n >> m >> L >> V;
    vector<double> x(n + 1), v(n + 1), a(n + 1);
    p.resize(m + 1, -1);
    p.push_back(L);
    rep(i, 1, n) cin >> x[i] >> v[i] >> a[i];
    rep(i, 1, m) cin >> p[i];
    vector<pair<int, int> > allranges;

    rep(i, 1, n) {
        int lft = -1, rgh = -1;
        if(a[i] == 0) {
            if(v[i] <= V) continue;
            lft = lb(m + 1, x[i]);
            rgh = m;
            if(lft <= m) allranges.push_back({lft, rgh});
        }
        if(a[i] > 0) {
            if(v[i] > V) {
                lft = lb(m + 1, x[i]); rgh = m; 
                if(p[lft - 1] == x[i]) lft--;
                if(lft <= m) allranges.push_back({lft, rgh});
            }
            if(v[i] == V) {
                lft = lb(m + 1, x[i]); rgh = m; 
                if(p[lft] == x[i]) lft++;
                if(lft <= m) allranges.push_back({lft, rgh});
            }
            if(v[i] < V) {
                double delt = (V * V - v[i] * v[i]) * 0.5 / a[i];
                lft = lb(m + 1, x[i] + delt);
                if(p[lft] == x[i]) lft++;
                if(lft <= m) allranges.push_back({lft, m});
            }
        }
    }
    cout << allranges.size() << ' ';
    cout << m - 1;
    cout << endl;
    return 0;
}
// 1
// 10 10 1000 10
// 100 100 0
// 101 100 0
// 200 100 0
// 300 100 0 400 100 0 500 100 0 600 100 0 900 100 0 800 100 0 1000 100 0 
// 100 200 300 400 500 600 666 700 800 900
